package com.zyc.app.woa.utils;

import android.content.Context;
import android.os.IBinder;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.zyc.app.woa.WoaApp;

/**
 * Author: yingchang.zhang
 * Date  : 2014/8/26
 */
public class ViewUtil {
    public static void hideSoftInputWindow(IBinder iBinder) {
        InputMethodManager imm =
                (InputMethodManager) WoaApp.getApp().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (null != imm) {
            imm.hideSoftInputFromWindow(iBinder, 0);
        }
    }

    public static void loadPicForImageView(String picUrl, ImageView imageView, int defaultImgRes) {
        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .cacheInMemory(true).cacheOnDisk(true)
                .resetViewBeforeLoading(true)
                .showImageForEmptyUri(defaultImgRes)
                .showImageOnFail(defaultImgRes)
                .showImageOnLoading(defaultImgRes).build();
        ImageLoader.getInstance().displayImage(picUrl, imageView, options);
    }

}
